<html>
<head>
	<#import "/common/common.ftl" as netCommon>
  	<@netCommon.commonStyle />
  	<title></title>
  	<@netCommon.commonScript />
  	<@netCommon.commonLayui />
</head>
<body class="layui-layout-body show-scroll-y">
	<div class="layuimini-container">
		<div class="layuimini-main">
			<fieldset class="layui-elem-field layui-field-title" id="searchField">
				<legend>档案架（柜）管理</legend>
			</fieldset>
				<div>
					<form class="layui-form layui-form-pane">
						<div class="layui-form-item">
							<label class="layui-form-label">位置名称</label>
							<div class="layui-input-inline">
								<input type="text" name="wzmc"id="wzmc" placeholder="" class="layui-input">
							</div>
							<label class="layui-form-label">位置编号</label>
							<div class="layui-input-inline">
								<input type="text" name="wzbh"id="wzbh" placeholder="" class="layui-input">
							</div>
							<div class="layui-inline">
								<button type="submit" class="layui-btn" lay-submit lay-filter="data-search-btn"><i class="layui-icon">&#xe615;</i> 搜 索</button>
								<button type="button" class="layui-btn" id="toAdd" lay-filter="data-add-btn"><i class="layui-icon">&#xe624;</i> 新 增</button>
							</div>
						</div>
					</form>
				</div>
			<div id="currentTableId"></div>
		</div>
	</div>
	<script type="text/javascript">
		layui.config({
		  base: '${request.contextPath}/static/plugins/cardTable/' //配置 layui 第三方扩展组件存放的基础目录
		}).extend({
		  cardTable: 'cardTable' 
		});
		layui.use(['table', 'form', 'jquery', 'cardTable'], function () {
			let table = layui.table;
			let form = layui.form;
			let $ = layui.jquery;
            let cardTable = layui.cardTable;
            cardTable.render({
                elem: '#currentTableId',
				url: '${request.contextPath}/wzxx/query',
				request: {
					idName: 'objectid'       //主键名称，默认：id
					, titleName: 'wzmc' //标题名称，默认：title
					, imageName: 'wzzp' //图片地址，默认：image
					, remarkName: 'wzms' //备注名称，默认：remark
					, timeName: 'czsj' //时间名称，默认：time
				},
				cardOnClick:function(elm,cardData){
					//showEdit(cardData.id);
				},
				buttons:[
					{"className":"layui-btn layui-btn-xs","name":"add","text":"<i class='layui-icon'>&#xe654;</i>"},
					{"className":"layui-btn layui-btn-xs","name":"detail","text":"<i class='layui-icon'>&#xe63c;</i>"},
					{"className":"layui-btn layui-btn-xs","name":"edit","text":"<i class='layui-icon'>&#xe642;</i>"}
				],
				buttonsClick:function(elm,cardData,gn){
					if(gn == "add"){
						showAddZwg(cardData.id);
					}else if(gn == "detail"){
						
					}else if(gn == "edit"){
						showEdit(cardData.id);
					}
				}
			});
            // 监听搜索操作
			form.on('submit(data-search-btn)', function (data) {
                queryJson = data.field;
                cardTable.reload("currentTableId", {
                    where: queryJson,
                });
                return false;
            });
            $("#toAdd").click(function(){
            	showEdit("");
            });
            function showAddZwg(objid){
            	objid = objid == undefined ? "" : objid;
            	layer.open({
        	        type: 2,
        	        title: '添加柜子',
        	        closeBtn: 1, 
        	        anim: 2,
        	        offset: '50px',
        	        area: ['1024px', '550px'],
        	        shadeClose: true,
        	        content: basePath+"/zwg/edit?wzxxOid="+objid
        	    });
            }
            function showEdit(objid){
            	objid = objid == undefined ? "" : objid;
            	layer.open({
        	        type: 2,
        	        title: '编辑',
        	        closeBtn: 1, 
        	        anim: 2,
        	        offset: '100px',
        	        area: ['500px', '350px'],
        	        shadeClose: true,
        	        content: basePath+"/wzxx/edit?objectid="+objid
        	    });
            }
		});
	</script>
</body>
</html>